package cn.scw;

import cn.scw.framework.protocol.DataResolverManager;
import cn.scw.framework.protocol.tcp.TcpServerManager;
import cn.scw.framework.protocol.udp.UdpServerManager;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

/**
 * 启动程序
 *
 * @author api
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class ApiApplication implements ApplicationRunner {
    public static void main(String[] args) {
        System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(ApiApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        new Thread(() -> {
            //初始化数据处理器
            DataResolverManager.getInstance().init();

            TcpServerManager.getManager().start();

            //初始化udp服务
            UdpServerManager.getManager().start();
        }).start();
    }
}
